package Airport;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class ProgramDemo {

	public static void main(String[] args) throws IOException {

		final File INPUT_FILE = new File("input.txt");
		final File OUTPUT_FILE = new File("output.txt");

		Scanner in = new Scanner(INPUT_FILE);
		BufferedWriter br = new BufferedWriter(new FileWriter(OUTPUT_FILE));

		int tracks = in.nextInt();
		int capacity = in.nextInt();
		int time = in.nextInt();

		Airport airport = Airport.getInstance(tracks, capacity, time);

		while (in.hasNextLine()) {

			String line = in.nextLine();

			if (line.contains("landing")) {

				int plane = Integer.parseInt(line.substring(0, 2));

				// Input faila go napravih vmesto 7 naprimer da pishe 07 za da
				// moga spokoino da vzimam po 2 cifri.
				int fuel = Integer.parseInt(line.substring(line.length() - 2));

				br.write(airport.requestLanding(plane, fuel));
				br.newLine();

			} else if (line.contains("taking")) {

				int plane = Integer.parseInt(line.substring(0, 2));

				br.write(airport.requestTakeoff(plane));
				br.newLine();

			} else if (line.contains("closed")) {

				int runway = Integer.parseInt(line.substring(7, 9));
				int closingTime = Integer
						.parseInt(line.substring(line.length() - 2));

				br.write(airport.closeRunway(runway, closingTime));
				br.newLine();

			}

			Airport.TimeTicks++;

		}

		br.close();
		in.close();
	}

}
